import { defineComponent, h } from "vue";
import imageLoader from './imageLoader'

const svgModules = import.meta.glob("@/assets/svg/**/*.svg");
console.log(svgModules);

export default defineComponent({
  name: "ImgIcon",
  props: {
    name: { type: String, default: "" },
  },
  async setup(props) {
    // const svgSrc = import.meta.glob(`@/assets/svg/${props.name}.svg`);
    let svgurl = `/src/assets/svg/${props.name}.svg` // svgModules[`/src/assets/svg/${props.name}.svg`];
    // let xxx = await imageLoader.dynamicImport(props.name)
    // console.log(svgurl);
    // console.log(xxx.default);
    // let svgSrc = URL.createObjectURL(new Blob([xxx.default], { type: 'image/svg+xml' }));
    // console.log(svgSrc);
    // const SvgComponent = `<img src="${svgurl}" alt="${props.name}" />`
    return () => h('img', { src: svgurl, alt: props.name });
  },
});